package com.example.teachingevaluationsystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.teachingevaluationsystem.entity.EvaluationPlan;
import com.example.teachingevaluationsystem.entity.EvaluationStatus;
import com.example.teachingevaluationsystem.service.EvaluationStatusService;
import com.example.teachingevaluationsystem.vo.EvaluationPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 评价状态表 前端控制器
 *
 * @author lp
 * @since 2022-04-04
 */
@RestController
@RequestMapping("/evaluate/evaluationStatus")
public class EvaluationStatusController {

  @Autowired EvaluationStatusService evaluationStatusService;

  /** 分页查询 评价计划 */
  @GetMapping("page")
  public Page<EvaluationStatus> evaluationPlanPage(Page<EvaluationStatus> evaluationPlanPage) {
    return evaluationStatusService.page(evaluationPlanPage, new LambdaQueryWrapper<EvaluationStatus>());
  }

  /** 保存或者 更新 评价计划 */
  @PostMapping
  public boolean save(@RequestBody EvaluationStatus evaluationStatus) {
    return evaluationStatusService.save(evaluationStatus);
  }

  /** 通过id删除题目 */
  @DeleteMapping
  public boolean deleteByIds(@RequestBody Long[] ids) {
    return evaluationStatusService.removeBatchByIds(Arrays.asList(ids));
  }

  @GetMapping("{evaluationStatusId}")
  public EvaluationStatus updateStatus(@PathVariable String evaluationStatusId) {
    return evaluationStatusService.getById(evaluationStatusId);
  }
}
